<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="http://x.xuebingsi.com/x-admin/v2.0/css/font.css">
    <link rel="stylesheet" href="http://x.xuebingsi.com/x-admin/v2.0/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="http://x.xuebingsi.com/x-admin/v2.0/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="http://x.xuebingsi.com/x-admin/v2.0/js/xadmin.js"></script>
    <script type="text/javascript" src="webjars/jquery/3.3.1"></script>

</head>

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名称</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="请输入名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="mail" lay-verify="required" autocomplete="off" placeholder="请输入名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">入职时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="entrytime" id="entrytime">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-block">
            <input type="text" name="department" lay-verify="required" autocomplete="off" placeholder="请输入名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" name="photo" lay-verify="required" autocomplete="off" placeholder="请输入名称"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>

    layui.use(['laydate', "jquery", "form"], function () {
        var $ = layui.jquery
            , form = layui.form
            , laydate = layui.laydate;



        form.on('submit(demo1)', function (data) {//点击提交按钮
            $.ajax({
                url: "/user/addUser",
                data: data.field,
                dataType: "json",
                type: "post",
                success: function (msg) {
                    if (msg.code == 0) {
                        tableIns.reload({
                            page: {
                                curr: 1
                            }
                        });
                        layer.msg(msg.msg);//提示后台传过来的信息
                        layer.close(openIndex);//关闭当前弹出的窗体
                    } else {
                        layer.msg(msg.msg);//提示后台传过来的信息
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            //执行一个laydate实例

        });
        laydate.render({
            elem: '#entrytime' //指定元素
        });
        form.render();
    });
</script>